|
|
|
|
|
|
|
Use Data Link File. This option allows you to load saved connection information from an MDL (Microsoft Data Link) file. |
|
|
|
|
|
|
|
|
Use ODBC Data Source Name. Here, you can select from one of the ODBC DSNs set up on your system. You can also click the Newbutton to create a new DSN, just as you would from the Control Panel. |
|
|
|
|
|
|
|
|
Use Connection String. This option allows you to specify a connection string directly. Clicking the Build button brings up a wizard that helps you build the connection string. |
|
|
|
|
|
|
|
|
Because you have already set up the BIBLIO data source, choose the Use ODBC Data Source Name option, and select BIBLIO from the drop-down list. |
|
|
|
|
|
|
|
|
Setting Up the Record Source |
|
|
|
|
|
|
|
|
Now that you have told the Data control that it needs to connect to the BIBLIO data source, you need to tell it what specific data to bring back from that data source. At designtime, you do so by selecting the RecordSource tab of the Property Pages dialog box, as shown in Figure 28.6. |
|
|
|
|
|
|
|
|
Figure 28.6
The RecordSource property tell the ADO
Data control exactly what data to retrieve. |
|
|
|
|
|
|
|
|
The ADO Data control acts like an ADO Command object, which you'll learn about in the upcoming section "The Command Object." You can use four types of commands to retrieve data: |
|
|
|
|
|
|
|
|
adCmdTextRuns an SQL query on the data source |
|
|
|
|
|
|
|
|
adCmdStoredProcCalls a stored procedure on a database server |
|
|
|
|
|
|
|
|
adCmdTableSpecifies the name of a database table; used to return the entire table |
|
|
|
|
|
|
|
|
adCmdUnknownUnknown command type |
|
|
|
|
|
|
|
|
Depending on which command type you select, the appropriate text box becomes enabled, and you can enter the command. For the sample program that uses the BIBLIO database, select the entire Publishers table. |
|
|
|
|
|
|
|
|
To select this table, first set the CommandType property to adCmdTable by selecting it from the drop-down list. The second drop-down box, Table or Stored Procedure Name, should then become enabled. Select the Publishers table from the list so that your settings look like those in Figure 28.6. Finally, click OK to close the dialog box and commit the changes. |
|
|
|
|
|